package edu.upenn.yas;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/** Action taken when a user requests to see a list of their friends. */
public class FriendsAction extends ActionSupport {

    private List<String> friends = null;

    public String execute() {
        Map session = ActionContext.getContext().getSession();
        if (session.get("login") != null) {
            String username = (String)session.get("username");
            friends = QueryEngine.instance.getFriends(username);
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

    public List<String> getFriends() { return friends; }
    public void setFriends(List<String> friends) { this.friends = friends; }
}
